#ifndef FSXSTRUCTS_H
#define FSXSTRUCTS_H

#include <windows.h>
#include <QString>
#include "./FSXAcceleration/SimConnect.h"
#include "./FSXAcceleration/gauges.h"
#include "../FsxWsUtils/mathhelper.h"
#include "fsxhelper.h"
#include "fsxsimconnectqtfier.h"
using namespace FsxWsUtils;

namespace FsxSimConnect {

//! Minimal data
/*! \author KWB */
// Can be used if e.g. just the object id is required
struct FSXAircraftMinimal {
    char atcType[32]; /*!< ATC type */
};

//! String data
/*! \author KWB */
// see http://msdn.microsoft.com/en-us/library/cc526981.aspx#AircraftStringData
// GPS WP PREV | NEXT ID wrong spelling in the docu with underscore
struct FSXAircraftStringAndMiscData {
    char atcType[32]; /*!< ATC type */
    char atcModel[32]; /*!< ATC model */
    char atcId[32]; /*!< ATC id (aka callsign) */
    char atcAirline[64]; /*!< ATC airline */
    char atcFlightNumber[8]; /*!< ATC flight number */
    char hsiStationIdent[8]; /*!< HSI stadion */
    char title[256]; /*!< Title */
    char category[32]; /*!< Category such as boat, plane, helicopter */
    char gpsWpPreviousId[32]; /*!< previous GPS waypoint */
    char gpsWpNextId[32]; /*!< next GPS waypoint */
    char gpsApproachAirportId[32]; /*!< approach airport GPS */
    char gpsApproachApproachId[32]; /*!< approach id GPS */
    char gpsApproachTransitionId[32]; /*!< GPS transition id */
    //! ATC type (QString)
    /*! \return ATC type */
    QString getAtcType() const { return QString (atcType);}
    //! ATC model (QString)
    /*! \return ATC model */
    QString getAtcModel() const { return QString (atcModel);}
    //! ATC airline (QString)
    /*! \return ATC airline */
    QString getAtcAirline() const { return QString (atcAirline);}
    //! ATC id, callsign (QString)
    /*! \return ATC id */
    QString getAtcId() const { return QString (atcId);}
    //! Category (QString)
    /*! \return category */
    QString getCategory() const { return QString (category);}



};

//! Position and speed data
/*! \author KWB */
// see http://msdn.microsoft.com/en-us/library/cc526981.aspx#AircraftPositionAndSpeedData
struct FSXAircraftPositionAndSpeedData {
    //! Constructor, set defined values
    FSXAircraftPositionAndSpeedData();
    double groundVelocityKts; /*!< ground velocity */
    double totalWorldVelocityFts; /*!< total world velocity */
    double velocityBodyZFts; /*!< aircraft Z velocity */
    double velocityBodyXFts; /*!< aircraft X velocity */
    double velocityBodyYFts; /*!< aircraft Y velocity */
    double velocityWorldZFts; /*!< aircraft Z velocity */
    double velocityWorldXFts; /*!< aircraft X velocity */
    double velocityWorldYFts; /*!< aircraft Y velocity */
    double accelerationBodyZFts2;  /*!< body acceleration Z */
    double accelerationBodydXFts2; /*!< body acceleration X */
    double accelerationBodydYFts2; /*!< body acceleration Y */
    double accelerationWorldZFts2; /*!< world acceleration Z */
    double accelerationWorldXFts2; /*!< world acceleration X */
    double accelerationWorldYFts2; /*!< world acceleration Y */
    double rotationVelocityBodyZFts;  /*!< rotation Vz */
    double rotationVelocityBodyXFts;  /*!< rotation Vx */
    double rotationVelocityBodyYFts;  /*!< rotation Vy */
    double relativeWindVelocityBodyZFts; /*!< relative wind z */
    double relativeWindVelocityBodyXFts; /*!< relative wind x */
    double relativeWindVelocityBodyYFts; /*!< relative wind y */
    double planeAltitudeFt; /*!< altitude */
    double planeAltitudeAboveGroundFt; /*!< agl */
    double groundAltitudeM; /*!< height */
    double planeLatitudeRad;  /*!< latitude */
    double planeLongitudeRad; /*!< longitude */
    double planePitchRad; /*!< pitch */
    double planeBankRad;  /*!< bank angle */
    double planeHeadingTrueRad; /*!< true heading */
    double planeHeadingMagneticRad; /*!< mag. heading */
    double magneticVariationDeg; /*!< mag.var */
    double surfaceType; /*!< Surface type */
    double simOnGround; /*!< Is on ground? */
    double angleOfAttackRad; /*!< Angle of attack, INCIDENCE ALPHA */
    double sideslipAngleRad; /*!< Sideslip, INCIDENCE BETA */
    //! Angle of attack (in degrees).
    /*! \return AoA */
    double angleOfAttackDeg() const { return MathHelper::radianToDegree(angleOfAttackRad) ; }
    //! Side slip (in degrees).
    /*! \return side slip */
    double sideslipAngleDeg() const { return MathHelper::radianToDegree(sideslipAngleRad) ; }
    //! Latitude.
    /*! \return latitude */
    double planeLatitudeDeg() const { return MathHelper::radianToDegree(planeLatitudeRad) ; }
    //! Longitude.
    /*! \return longitude */
    double planeLongitudeDeg() const { return MathHelper::radianToDegree(planeLongitudeRad) ; }
    //! True heading degrees
    /*! \return true heading degress */
    double planeHeadingTrueDeg() const { return MathHelper::radianToDegree(planeHeadingTrueRad) ;}
    //! Bank degress
    /*! \return bank degrees */
    double planeBankDeg() const { return MathHelper::radianToDegree(planeBankRad) ; }
    //! Pitch degrees
    /*! \return pitch degress */
    double planePitchDeg() const { return MathHelper::radianToDegree(planePitchRad) ; }
    //! Surface text
    /*! \return Surface */
    QString surfaceText() const { return FSXSimConnectQtfier::simConnectSurfaceTypeToString(surfaceType); }
};

//! Instrumentation data
// see http://msdn.microsoft.com/en-us/library/cc526981.aspx#AircraftFlightInstrumentationData
struct FSXAircraftInstrumentationData {
    FSXAircraftInstrumentationData();
    double airspeedTrueKts; /*!< TAS */
    double airspeedIndicatedKts; /*!< IAS */
    double airspeedCalibratedKts; /*!< CAS */
    double airspeedBarberPoleKnots; /*!< limiting speed */
    double airspeedMach; /*!< Mach */
    double verticalSpeedFts;   /*!< vertical speed */
    double machMaxOperateMach; /*!< max. mach */
    bool   stallWarning; /*!< stall warning */
    bool   overspeedWarning; /*!< overspeed warning */
    double barberPoleMach; /*!< limiting speed in mach */
    double indicatedAltitudeFt; /*!< indicated altitude */
    double kohlsmanSettingMb; /*!< Kohlsman */
    double kohlsmanSettingInHg; /*!< Kohlsman */
    double attitudeIndicatorPitchRad; /*!< pitch [rad] */
    double attitudeIndicatorBankRad;  /*!< bank [rad] */
    double attitudeBarsPositionPercentOver; /*!< percent over */
    double angleOfAttackIndicatorRad; /*!< AoA [rad] */
};

//! Avionics data
// http://msdn.microsoft.com/en-us/library/cc526981.aspx#AircraftAvionicsData
struct FSXAircraftAvionicsData {
    //! Constructor
    FSXAircraftAvionicsData() : transponderCode(-1), transponderAvailable(false),
        nav1ActiveMHz(-1), nav2ActiveMHz(-1), com1ActiveMHz(-1), com2ActiveMHz(-1)
    {}
    double transponderCode; /*!< BCO16 Octal 0000-7777 */
    double transponderAvailable; /*!< transponder available? */
    double nav1ActiveMHz; /*!< active Nav1 frequency */
    double nav2ActiveMHz; /*!< active Nav2 frequency */
    double com1ActiveMHz; /*!< active Com1 frequency */
    double com2ActiveMHz; /*!< active Com2 frequency */
    double adf1ActiveMHz; /*!< active Com1 frequency */
    double adf2ActiveMHz; /*!< active Com2 frequency */
    //! Formatted transponder code.
    /*! \return formatted transponder code */
    QString transponderCodeFormatted() const { return FSXHelper::transponderCode(transponderCode);}
    //! Formatted NAV1 frequency.
    /*! \return formatted frequency */
    QString nav1ActiveMHzFormatted() const { return FSXHelper::formattedNavFrequency(nav1ActiveMHz); }
    //! Formatted NAV2 frequency.
    /*! \return formatted frequency */
    QString nav2ActiveMHzFormatted() const { return FSXHelper::formattedNavFrequency(nav2ActiveMHz); }
    //! Formatted COM1 frequency.
    /*! \return formatted frequency */
    QString com1ActiveMHzFormatted() const { return FSXHelper::formattedNavFrequency(com1ActiveMHz); }
    //! Formatted COM2 frequency.
    /*! \return formatted frequency */
    QString com2ActiveMHzFormatted() const { return FSXHelper::formattedRadioFrequency(com2ActiveMHz); }
    //! Formatted ADF frequency.
    /*! \return formatted frequency */
    QString adf1ActiveKHzFormatted() const { return FSXHelper::formattedAdfFrequency(adf1ActiveMHz); }
    //! Formatted ADF frequency.
    /*! \return formatted frequency */
    QString adf2ActiveKHzFormatted() const { return FSXHelper::formattedAdfFrequency(adf2ActiveMHz); }
};
} // namespace

#endif // FSXSTRUCTS_H
